// pages/ptorder/ptorder.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navindex: 0,
    According: false,
    nav: [
      { txt: '待处理' },
      { txt: '服务中' },
      { txt: '已完成' },
      { txt: '全部' },
    ],
    orderdeil: [
      { 
        title: '室内整体清洁(3小时)',
        data: '2018-01-10  10:00',
        ads: '凤城二路海洋大厦1001',
      },
      {
        title: '室内整体清洁(3小时)',
        data: '2018-01-10  10:00',
        ads: '凤城二路海洋大厦1001',
      },
      {
        title: '室内整体清洁(3小时)',
        data: '2018-01-10  10:00',
        ads: '凤城二路海洋大厦1001',
      },
      {
        title: '室内整体清洁(3小时)',
        data: '2018-01-10  10:00',
        ads: '凤城二路海洋大厦1001',
      },
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    userInfo: {}
  },
  start_problem: function () {
    app.navTo('../problem/problem')
  },
  //开始服务
  start_service: function () {
    app.navTo('../ordservice/ordservice')
  },
  //订单详情
  start_kdxq:function(e){
    var id = e.currentTarget.dataset.id;
    app.navTo('../ptorderdeil/ptorderdeil?id=' + id)
  },
  //拨打电话
  start_phone:function(){
    wx.makePhoneCall({
      phoneNumber: '1340000' 
    })
  },
  start_achieve:function(e){
    wx.showToast({
      title: '完成服务',
      duration: 3000,
      icon: 'success',
    })
  },
  start_remove: function (e) {
    var index = e.currentTarget.dataset.index;
    var orderdeil = this.data.orderdeil;
    orderdeil.splice(index, 1);              // 删除列表里这个商品
    wx.showToast({
      title: '删除订单',
      duration: 3000,
      icon: 'success',
    })
    this.setData({
      orderdeil: orderdeil
    });
  },
  //地址
  start_ads: function (e) {
    wx.openLocation({
      latitude: 23.362490,
      longitude: 116.715790,
      scale: 18,
      name: '华乾大厦',
      address: '金平区长平路93号'
    })
  },
  click: function (e) {
    var id = e.currentTarget.dataset.id;
    console.log(id)
    this.setData({
      navindex: id
    })
    // wx.request({
    //   url: 'https://yunying.135k.com/api/goods/myposs',
    //   data: {
    //   },
    //   success: function (res) {
    //     that.setData({
    //       list: res.data.data
    //     })
    //   }
    // })
  },
  //底部
  single: function () {
    app.radTo('../single/single')
  },
  ptmy: function () {
    app.radTo('../ptmy/ptmy')
  },
  ptorder: function () {
    app.radTo('../ptorder/ptorder')
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this;
    var HQgoods = that.data.orderdeil;
    if (HQgoods.length == 0) {
      that.setData({
        According: true,
      })
    } else {
      that.setData({
        According: false,
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})